//
//  UIView+Extension.h
//  SinaWeibo
//
//  Created by chensir on 15/10/13.
//  Copyright (c) 2015年 ZT. All rights reserved.
//

#import <UIKit/UIKit.h>

typedef enum : NSUInteger {
    /// 图片在左，文字在右
    OrgImagePositionStyleDefault,
    /// 图片在右，文字在左
    OrgImagePositionStyleRight,
    /// 图片在上，文字在下
    OrgImagePositionStyleTop,
    /// 图片在下，文字在上
    OrgImagePositionStyleBottom,
} OrgImagePositionStyle;

typedef NS_ENUM(NSInteger, BorderDirectionType) {
    BorderDirectionTop = 0,
    BorderDirectionLeft,
    BorderDirectionBottom,
    BorderDirectionRight
};

@interface UIView (Extension)

@property (nonatomic, assign) CGFloat wb_x;
@property (nonatomic, assign) CGFloat wb_y;
@property (nonatomic, assign) CGFloat wb_centerX;
@property (nonatomic, assign) CGFloat wb_centerY;
@property (nonatomic, assign) CGFloat wb_width;
@property (nonatomic, assign) CGFloat wb_height;
@property (nonatomic, assign) CGSize wb_size;
@property (nonatomic, assign) CGPoint wb_origin;

@property (nonatomic, assign) CGFloat wb_top;
@property (nonatomic, assign) CGFloat wb_bottom;
@property (nonatomic, assign) CGFloat wb_left;
@property (nonatomic, assign) CGFloat wb_right;


@property (nonatomic, retain) NSObject *var_attachment; //在视图中附加一个绑定数据

@property (nonatomic, retain) NSObject *var_attachmentView; //在视图中附加一个绑定数据

@property (nonatomic, retain) NSObject *var_attachmentIndicatorView; //在菊花附加一个绑定数据

@property (nonatomic, retain) NSObject *var_attachmentLoadingView; //在视图中附加一个绑定数据


- (CGPoint)wb_offsetFromView:(UIView*)otherView;
-(void)wb_removeAllSubViews;
- (UIView *)wb_subViewOfClassName:(NSString*)className;
/**
 * Finds the first descendant view (including this view) that is a member of a particular class.
 */
- (UIView*)wb_descendantOrSelfWithClass:(Class)cls;

/**
 * Finds the first ancestor view (including this view) that is a member of a particular class.
 */
- (UIView*)wb_ancestorOrSelfWithClass:(Class)cls;

/**
 为UIView的某个方向添加边框
 
 @param direction 边框方向
 @param color 边框颜色
 @param width 边框宽度
 */
- (void)wb_addLineOnDirection:(BorderDirectionType)direction color:(UIColor *)color width:(CGFloat)width;

@end

@interface UIButton (Extension)

/**
 *  设置图片与文字样式
 *
 *  @param imagePositionStyle     图片位置样式
 *  @param spacing                图片与文字之间的间距
 */
- (void)wb_setImagePositionStyle:(OrgImagePositionStyle)imagePositionStyle spacing:(CGFloat)spacing;

+ (instancetype)wb_buttonWithFrame:(CGRect)frame
                              title:(NSString *)title
                             target:(id)target
                             method:(SEL)method;

+ (instancetype)wb_buttonWithFrame:(CGRect)frame
                              title:(NSString *)title
                           fontSize:(CGFloat)fontSize
                         titleColor:(UIColor *)titleColor
                            bgColor:(UIColor *)bgColor
                             target:(id)target
                             method:(SEL)method;

+ (instancetype)wb_buttonWithFrame:(CGRect)frame
                              title:(NSString *)title
                           fontSize:(CGFloat)fontSize
                         titleColor:(UIColor *)titleColor
                            bgColor:(UIColor *)bgColor
                              image:(NSString *)image
                            bgImage:(NSString *)bgImage
                             target:(id)target
                             method:(SEL)method;

@end
